<template>
  <div>
    <div class="container">
      <p class="bigTitle">{{ $t("新闻动态") }}</p>
      <div class="news-box">
        <div
          class="items"
          v-for="item in newsData.list"
          :key="item.id"
          @click="goLink(item.id)"
        >
          <div class="img-box">
            <img :src="item.thumb" alt="" class="image" />
          </div>
          <div class="text-box">
            <p class="title">{{ item.title }}</p>
            <p class="time">{{ item.create_time }}</p>
          </div>
        </div>
      </div>
      <el-pagination
        background
        layout="prev, pager, next, jumper"
        :total="newsData.count"
        :page-size="4"
        @current-change="pageChange"
      >
      </el-pagination>
    </div>
    <div class="container_mobile">
      <p class="bigTitle">{{ $t("新闻动态") }}</p>
      <div class="news-box">
        <div
          class="items"
          v-for="item in newsData.list"
          :key="item.id"
          @click="goLink(item.id)"
        >
          <img :src="item.thumb" alt="" class="image" />
          <div class="text-box">
            <p class="title">{{ item.title }}</p>
            <p class="time">{{ item.create_time }}</p>
          </div>
        </div>
      </div>
      <el-pagination
        background
        layout="prev, pager, next, jumper"
        :total="newsData.count"
        :page-size="4"
        @current-change="pageChange"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    newsData: {
      type: Object,
    },
  },
  data() {
    return {};
  },
  methods: {
    goLink(id) {
      this.$router.push({
        path: this.$i18n.path("newsDetail"),
        query: {
          id: id,
        },
      });
    },
    pageChange(e) {
      this.$emit("page", e);
    },
  },
};
</script>

<style lang="less" scoped>
.container_mobile {
  display: none;
}
.container {
  display: block;
  padding: 100rem 200rem 150rem 200rem;
  background: #fafafa;

  .bigTitle {
    font-size: 54rem;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #333333;
    text-align: center;
    margin: 0;
  }

  .news-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 40rem;
    margin-top: 98rem;

    .items {
      width: 700rem;
      height: 700rem;
      background: #ffffff;
      border-radius: 20rem;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      cursor: pointer;
      &:hover {
        .image {
          transform: scale(1.2);
        }
      }

      .img-box {
        width: 100%;
        height: 700rem;
        overflow: hidden;
        .image {
          width: 100%;
          height: 100%;
          transition: 0.6s;
        }
      }

      .text-box {
        margin-top: 30rem;
        margin-bottom: 30rem;
        margin-left: 55rem;
        display: flex;
        flex-direction: column;
        gap: 37rem;

        .title {
          font-size: 26rem;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #333333;
          margin: 0;
        }
        .time {
          font-size: 20rem;
          font-family: Source Han Sans CN;
          font-weight: 300;
          color: #333333;
          margin: 0;
        }
      }
    }
  }
  :deep(.el-pagination) {
    margin: 30rem 0;
    text-align: center;
  }
}
@media (max-width: 900px) {
  .container {
    display: none;
  }
  .container_mobile {
    display: block;
    padding: 10px;
    background: #fafafa;

    .bigTitle {
      font-size: 18px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #333333;
      text-align: center;
      margin: 0;
    }

    .news-box {
      .items {
        margin-top: 10px;
        width: 100%;
        height: auto;
        background: #ffffff;
        border-radius: 7px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        cursor: pointer;
        &:hover {
          .image {
            transform: none;
          }
        }

        .image {
          width: 100%;
        }
        .text-box {
          padding: 10px;
          display: flex;
          flex-direction: column;

          .title {
            font-size: 13px;
            font-family: Source Han Sans CN;
            font-weight: 500;
            color: #333333;
            margin: 0;
          }
          .time {
            margin: 10px 0 0 0;
            font-size: 10px;
            font-family: Source Han Sans CN;
            font-weight: 300;
            color: #333333;
          }
        }
      }
    }
    :deep(.el-pagination) {
      margin: 30px 0;
      text-align: center;
    }
  }
}
</style>
